package com.itheima.task;

public class task5 {
    public static void main(String[] args) {
        /*给定两个以字符串形式表示的非负整数num1和num2，返回num1和num2的乘积，它们的乘积也表示为字符串形式。
        注意：需要用己有的知识完成。*/
        //1. 先定义两个非负数字字符串
        String str1 = "15";
        String str2 = "15";
        int num1 = stringToNumber(str1);
        int num2 = stringToNumber(str2);
        int res = num1 * num2;
        StringBuilder sb = new StringBuilder();
        if(res!=0){
            while (res != 0) {
                int num = res % 10;
                res = res / 10;
                char c = (char) (num + 48);
                sb.append(c);
            }
        }else {
            sb.append(0);
        }

        sb.reverse();
        String s = sb.toString();
        System.out.println(s);
        //System.out.println(res);
        // System.out.println(num1);
    }

    public static int stringToNumber(String str) {
        int result = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int num = c - 48;
            result = result * 10 + num;
        }
        return result;
    }
}
